<?php

require_once("configure.php");

$Name = $_POST["name"];
$Password = $_POST["password"];

$MySqlLinkId = mysql_connect(DBHost, DBUser, DBPwd);
if($MySqlLinkId == FALSE)
{
	echo("({ErrCode:1, ErrMsg:'链接数据库失败！'})");
	exit();
}

if(FALSE == mysql_select_db(DB, $MySqlLinkId))
{
	echo("({ErrCode:2, ErrMsg:'".json_encode(mysql_error($MySqlLinkId))."'})");
	mysql_close($MySqlLinkId);
	exit();
}

$result = mysql_query("SELECT Name, Password FROM Account WHERE Name='".mysql_real_escape_string($Name)."' AND Password='".mysql_real_escape_string($Password)."'", $MySqlLinkId);
$num = mysql_num_rows($result);
mysql_free_result($result);
mysql_close($MySqlLinkId);

if($num != FALSE && $num > 0)
	echo("({ErrCode:0, ErrMsg:''})");
else
	echo("({ErrCode:3, ErrMsg:'登陆失败，用户名或密码错误！'})");

?>